package com.example.computer_exam_training_sys.controller;

import com.example.computer_exam_training_sys.entity.CoursesInfo;
import com.example.computer_exam_training_sys.entity.KnowledgePointInfo;
import com.example.computer_exam_training_sys.service.KnowledgePointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/KnowledgePoint")
@CrossOrigin
public class KnowledgePointController {

    @Autowired
    private KnowledgePointService knowledgePointService;

    //http://localhost:8080/KnowledgePoint/findById?pointId=5
    // 查询单独知识点
    @GetMapping("/findById")
    public KnowledgePointInfo findById(int pointId){
        return knowledgePointService.findById(pointId);
    }

    //http://localhost:8080/KnowledgePoint/all
    // 查询全部知识点
    @GetMapping("/all")
    public List<KnowledgePointInfo> findAll(){
        return knowledgePointService.findAll();
    }

    //http://localhost:8080/KnowledgePoint/course?courseId=1
    // 按课程查询知识点
    @GetMapping("/course")
    public List<KnowledgePointInfo> findByCourse(int courseId){
        return knowledgePointService.findByCourse(courseId);
    }


}
